package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.Backbone;
import com.example.Laboratory.Service.BackboneService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;

@Api(value = "Backbone", description = "研究队伍-骨干")
@RestController
@RequestMapping(value = "/Backbone")
@CrossOrigin
public class BackboneController {

    @Autowired
    BackboneService backboneService;

    @ApiOperation(value = "添加骨干信息", notes = "添加骨干信息")
    @RequestMapping(value = "/addBackbone", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object addBackbone (Backbone b) throws IOException {
        return ResultCode.SUCCESS.result(backboneService.addBackbone(b));
    }

    @ApiOperation(value = "删除骨干信息", notes = "删除骨干信息")
    @RequestMapping(value = "/deleteBackbone", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object deleteBackbone (@RequestParam int backbone_id) throws IOException {
        return ResultCode.SUCCESS.result(backboneService.deleteBackbone(backbone_id));
    }

    @ApiOperation(value = "查找骨干信息", notes = "查找骨干信息")
    @RequestMapping(value = "/researchBackbone", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object researchBackbone ( ) throws IOException {
        return ResultCode.SUCCESS.result(backboneService.researchBackbone());
    }

    @ApiOperation(value = "修改骨干信息", notes = "修改骨干信息")
    @RequestMapping(value = "/reviseBackbone", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object reviseBackbone (Backbone b) throws IOException {
        return ResultCode.SUCCESS.result(backboneService.reviseBackbone(b));
    }
}
